package com.ftg.learn.chapter09.collection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *  学习一下map
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/8/17 13:11
 */

public class LearnMap {

    public static void main(String[] args) {

        //hash结构 k,v  k:key 主键 唯一
        Map<String,String> map=new HashMap<>(2);

        map.put("name","li");
        //覆盖
        map.put("name","cc");
        map.put("age","20");
        System.out.println(map.containsValue("li"));

        map.put(null,null);
        System.out.println(map.get(null));
        System.out.println(map.size());
        System.out.println(map);

        Map<String,String> map1=new HashMap<>(2);
        map1.put("name","uu");
        map1.put("age","22");
        System.out.println(map1.size());
        System.out.println(map1);

        map1.remove("name");
        System.out.println(map1);

//        把多个map加到list里
        List<Map<String,String>> list = new ArrayList<>();
        list.add(map);
        list.add(map1);
        System.out.println(list);
        for (Map<String,String> map2:list) {
            System.out.println(map2);
//            System.out.println("name==>"+ map2.get("name"));
//            if(map2.containsValue("cc")){
//
//            }
        }
    }
}
